package com.silp.ontouchevent;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;

public class OntouchActivity extends Activity {
    private Button mButton;
	private int action;
	private RadioButton mRadio;
	private ImageView mImage;

	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mButton = (Button) findViewById(R.id.btn1);
        mImage  = (ImageView)findViewById(R.id.imgv1);
        mRadio  = (RadioButton)findViewById(R.id.rdiobtn1);
        mButton.setOnTouchListener(new OnTouchListener() {
			
			public boolean onTouch(View v, MotionEvent event) {
				// TODO Auto-generated method stub
				v=mButton;
				action = event.getAction();// &MotionEvent.ACTION_MASK;
				switch (action) {
				case MotionEvent.ACTION_DOWN:
					Log.d("TTTH","Button Action Down");
					break;

				case MotionEvent.ACTION_MOVE :
					Log.d("TTTH","Action Move");
					break;
				case MotionEvent.ACTION_UP :
					Log.d("TTTH","Button Action Up");
				case MotionEvent.ACTION_OUTSIDE :
					Log.d("TTTH"," Button Action Outside");
				}
				
				
				return true;
			}
		});
        mImage.setOnTouchListener(new OnTouchListener() {
			
			public boolean onTouch(View v, MotionEvent event) {
				v=mImage;
				action = event.getAction();// &MotionEvent.ACTION_MASK;
				switch (action) {
				case MotionEvent.ACTION_DOWN:
					Log.d("TTTH","Image Action Down");
					break;

				case MotionEvent.ACTION_MOVE :
					Log.d("TTTH","Image Move");
					break;
				case MotionEvent.ACTION_UP :
					Log.d("TTTH","Image Action Up");
				case MotionEvent.ACTION_OUTSIDE :
					Log.d("TTTH"," Image Action Outside");
				}
				
				return true;
			}
		});
        mRadio.setOnTouchListener(new OnTouchListener() {
			
			public boolean onTouch(View v, MotionEvent event) {
				v=mImage;
				action = event.getAction();// &MotionEvent.ACTION_MASK;
				switch (action) {
				case MotionEvent.ACTION_DOWN:
					Log.d("TTTH","Radio Action Down");
					break;

				case MotionEvent.ACTION_MOVE :
					Log.d("TTTH","Radio Action Move");
					break;
				case MotionEvent.ACTION_UP :
					Log.d("TTTH","Image Action Up");
				case MotionEvent.ACTION_OUTSIDE :
					Log.d("TTTH"," Radio Action Outside");
				}
				
				return true;
			}
		});
    }
    	
	/*@Override
	public boolean onTouchEvent(MotionEvent event) {
		action = event.getAction() &mButton.ACTION_MASK;
		switch (action) {
		case MotionEvent.ACTION_DOWN:
			Log.d("TTTH","Action Down");
			break;

		case MotionEvent.ACTION_MOVE :
			Log.d("TTTH","Action Move");
			break;
		case MotionEvent.ACTION_UP :
			Log.d("TTTH","Action Up");
		case MotionEvent.ACTION_OUTSIDE :
			Log.d("TTTH","Action Outside");
		}
		return true;*/
	}
